package com.oren.util;

import com.oren.base.pojo.Page;
import org.apache.ibatis.session.RowBounds;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: wangshiwei
 * Date: 2018/7/27
 * Time: 14:02
 * describe: 分页工具
 */
public  class PageUtil {


    /**
     * 分页的数据
     * @param rows
     * @param total
     * @return
     */
    public static Page getPageList(List rows, int total){
        Page page=new Page();
        page.setTotal(total);
        page.setRows(rows);
        return page;
    }

    /**
     * 设置分页的相关参数
     * @param pageNum
     * @param pageSize
     * @return
     */
    public static RowBounds getBound(int pageNum,int pageSize){
        int begin=(pageNum-1)*pageSize;
        return new RowBounds(begin,pageSize);
    }
}
